package crack.lshape.yijian_mesh;

import java.io.IOException;

import crack.AbstractLshapeUsingSDAElementDemo;

import math2.MathUtilities;
import fem2.AbstractStructuralCrackDemo;
import fem2.Element;
import fem2.MaterialModel;
import fem2.Mesh;
import fem2.MeshGenerator;
import fem2.MeshPart;
import fem2.Model;
import fem2.element.crack_sda.SOSConstantJumpCSTElement2;
import fem2.material.cohesive_law.CohesiveLaw;
import fem2.material.cohesive_law.Mode1ExponentialCohesiveLaw;
import fem2.pre_and_post.GidMeshGenerator;

public class LshapeTriMeshYijianSOSConstantJumpCSTElement2AndExponentialCohesiveLaw extends
		AbstractLshapeUsingSDAElementDemo {

	public LshapeTriMeshYijianSOSConstantJumpCSTElement2AndExponentialCohesiveLaw() {
		meshFileName = "mesh1-sos.msh";
	}

	@Override
	public Mesh createMesh() {
		String fn = projectDir + '/' + projectName + '/' + meshFileName;
		MeshGenerator mg = new GidMeshGenerator(fn);
		Mesh mesh = mg.getMesh(2);
		return mesh;
	}

	@Override
	public CohesiveLaw createCohesiveLaw(Model m) {
		double ft = 2.7;
		double Gf = 0.065;
		double km = -1e5;
		return new Mode1ExponentialCohesiveLaw(Gf, ft, km);
	}

	@Override
	public Element createElement(MeshPart mp, MaterialModel mm, CohesiveLaw cl) {
		Element e = new SOSConstantJumpCSTElement2(mp, mm, cl);
		return e;
	}

	public static void main(String[] args) throws IOException {

		AbstractStructuralCrackDemo sample = new LshapeTriMeshYijianSOSConstantJumpCSTElement2AndExponentialCohesiveLaw();

		// double[] lambda = MyLinAlg.createLambdaArray(7.5, 0.1, 7.8);
		// double[] lambda = MyLinAlg.createLambdaArray(7.5, 0.1, 7.6, 0.05,
		// 10);
		// double[] lambda = MyLinAlg.createLambdaArray(7.5, 0.1, 7.6, 0.05,
		// 15);
		// double[] lambda = MyLinAlg.createLambdaArray(7.5, 0.1, 7.6, 0.05,
		// 20);
		// double[] lambda = MyLinAlg.createLambdaArray(7.5, 0.1, 7.6, 0.05,
		// 25);
		// double[] lambda = MyLinAlg.createLambdaArray(7.5, 0.1, 7.6, 0.05,
		// 30);
//		double[] lambda = MyLinAlg.createLambdaArray(7.5, 0.1, 7.6, 0.05, 35);
		double[] lambda = MathUtilities.createLambdaArray(7.5, 0.1, 7.6, 0.05, 40);

		sample.run(lambda);

	}
}
